{% extends 'layout/basic.html' %}
{%  load static %}
{% block css %}
<link rel="stylesheet" href="{% static 'css/register.css' %}">
{%  endblock %}
{% block content %}

<div class="container a">
    <form action="" method="post" novalidate> 
         {% csrf_token %}  
    <h3>注册界面</h3>
    {% for item in form %}
    {% if item.name == 'code' %}
    <div class="mb-3 clearfix b">
        <label  class="form-label "><b>{{item.label}}</b></label>
        <div class="row">
        <div class="col-md-6">{{ item }}</div>
        
        <div class="col-md-6"><input type="button" value="点击获取验证码" class="btn btn-light" id="btnSms"></div>
        <span style="color: red;"> {{item.errors.0}}</span>
        </div>
    </div>
    {% else %}
    <div class="mb-3 b">
        <label  class="form-label"><b>{{item.label}}</b></label>
        {{ item }}
        <span style="color: red;"> {{item.errors.0}}</span>
    </div>
    {% endif %}
{% endfor %}
<button type="submit " class="btn btn-primary b">注册</button>
</form>
</div>
{% endblock %}

{% block js %}
<script>
    $(function(){
        BindBtnSms()
    });

    function BindBtnSms(){
        $('#btnSms').click(function(){
            var MobilePhone=$('#id_mobile_phone').val();
            $.ajax({
                data:{'mobile_phone':MobilePhone,'tpl':'register'},
                method:'get',
                url:'/send/sms/',
                success:function(res){
                    console.log(MobilePhone)
                }
            })
        })
     }

</script>
{% endblock %}
